<<<<<<< HEAD
data1=read.csv("ADdata2.csv",header = TRUE,sep = ",")#读取csv文件
View(data1)#看csv文件
data2=read.table("ADdata11.txt",header = TRUE,sep = "\t")
data2=read.table("ADdata1.txt",header = TRUE,sep = "\t")
data3=read.table("ADdata4.txt",header = TRUE,sep = " ")
library(openxlsx)
data <- read.xlsx("ADdata3.xlsx")#以上均是读文件并引入data向量
data4=data
merge_data1=merge(data1,data2,by.x=1,by.y=0)#以同样的项目合并data1、data2内容
merge_data2=merge(merge_data1,data3,by.x=1,by.y=0)
merge_data=merge(merge_data2,data4,by.x=1,by.y=1)#同上
write.csv(merge_data,"合并后.csv",row.names = FALSE)#存合并后的csv文件
library(writexl)
write_xlsx(merge_data,path = "合并后.xlsx")#存合并后的xlsx文件
write.table(merge_data,"合并后.txt", sep = "\t", row.names = FALSE)#存txt文件


clin=read.csv("clin_inf.csv",header = TRUE,sep = " ")





number=sample(1:50,10,replace = TRUE)#引入number变量
count=0
for (number in number) {
  if (number > 10) {
    count <- count + 1
  }
}#for循环函数

print(paste("大于10的元素个数:", count))#输出
i=1
while (i <= length(number)) {
  if (number[i] > 10) {
    count <- count + 1
  }
  i <- i + 1  # 索引递增
}#while循环函数

print(paste("大于10的元素个数:", count))
=======
data1=read.csv("ADdata2.csv",header = TRUE,sep = ",")#读取csv文件
View(data1)#看csv文件
data2=read.table("ADdata11.txt",header = TRUE,sep = "\t")
data2=read.table("ADdata1.txt",header = TRUE,sep = "\t")
data3=read.table("ADdata4.txt",header = TRUE,sep = " ")
library(openxlsx)
data <- read.xlsx("ADdata3.xlsx")#以上均是读文件并引入data向量
data4=data
merge_data1=merge(data1,data2,by.x=1,by.y=0)#以同样的项目合并data1、data2内容
merge_data2=merge(merge_data1,data3,by.x=1,by.y=0)
merge_data=merge(merge_data2,data4,by.x=1,by.y=1)#同上
write.csv(merge_data,"合并后.csv",row.names = FALSE)#存合并后的csv文件
library(writexl)
write_xlsx(merge_data,path = "合并后.xlsx")#存合并后的xlsx文件
write.table(merge_data,"合并后.txt", sep = "\t", row.names = FALSE)#存txt文件


clin=read.csv("clin_inf.csv",header = TRUE,sep = " ")

exp1=read.csv("exp_inf.csv",header=TRUE,sep=" ")
count=read.csv("count.csv",header = TRUE,sep=" ")
ID=read.csv("ID_annoation.csv",header = TRUE,sep=" ")#读取文件
merge_Data=merge(clin,exp1,by.x=1,by.y=1)#合并clin和exp1文件
rownames(merge_Data)=merge_Data$样本名称
coldata1=ID[,1]#提取出ID文件的第一列
coldata2 <- gsub("\\...","",coldata1)#先删掉小数点后第二位
coldata3 <- gsub("\\..","",coldata2)#再删掉小数点后一位
ID$gene_id <- coldata3#改为规范化后的列
rownames(ID)=ID$gene_id
rowdata1 = colnames(count)#提取出count文件的列名
gsub(".$","","PTB008D")
rowdata2=gsub(".$","",rowdata1)#将rowdata1数据最后一个字节删去
rowdata3 <- gsub("X(...)$","PTB\\1",rowdata2)#把X带三位数字的X替代为PTB
rowdata4 <- gsub("X","XYA",rowdata3)#把带八位数字的x替代XYA
colnames(count) <- rowdata4
merge_Data=merge_Data[match(colnames(count),rownames(merge_Data)),]
ID=ID[match(rownames(count),rownames(ID)),]
library(Biobase)
count <- as.matrix(count)
eset <- ExpressionSet(assayData = as.matrix(count),
                      phenoData = new("AnnotatedDataFrame", data = merge_data),
                      featureData = new("AnnotatedDataFrame", data = ID))
eset2 <- eset[1:10,1:10]#从中提取前十行和前十列内容存到eset2 origin/master


number=sample(1:50,10,replace = TRUE)#引入number变量
count=0
for (number in number) {
  if (number > 10) {
    count <- count + 1
  }
}#for循环函数

print(paste("大于10的元素个数:", count))#输出
i=1
while (i <= length(number)) {
  if (number[i] > 10) {
    count <- count + 1
  }
  i <- i + 1  # 索引递增
}#while循环函数
print(paste("大于9的元素个数:", count))








